package cn.hfuu.spark;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class FindMaxNumber {
    public static void main(String[] args) {
        String filePath = "\"C:\\Users\\唐凤穎\\Desktop\\data.txt\""; // 指定文件路径
        double maxNumber = Double.NEGATIVE_INFINITY; // 初始化最大数为负无穷大

        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
            String line;
            while ((line = reader.readLine()) != null) {
                // 使用正则表达式匹配数字
                String[] numbers = line.split("\\D+");
                for (String numberStr : numbers) {
                    if (!numberStr.isEmpty()) {
                        double number = Double.parseDouble(numberStr);
                        if (number > maxNumber) {
                            maxNumber = number;
                        }
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.out.println("最大的数是: " + maxNumber);
    }
}